﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ReportZhanLin2EasyUI.aspx.cs" Inherits="IHISCETeim.Web.MachineSys.FTradeModel.ReportZhanLin2EasyUI" %>

<%--帐龄报表2--%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../EasyUI/themes/default/easyui.css"/>
	<link rel="stylesheet" type="text/css" href="../EasyUI/themes/icon.css" />
	<script type="text/javascript" src="../js/jquery-1.7.2.min.js"></script>   
	<script type="text/javascript" src="../EasyUI/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../EasyUI/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="../EasyUI/easyui-formatter_20140718.js"></script>
     <link href="../themes/css/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
    <script src="../js/DWZ/jquery.autocomplete.js" type="text/javascript"></script>

    <script type="text/javascript">
        ///自适应宽高
       $(window).resize(function(){		    
             $("#dg").datagrid({
                    width: '100%',
                    height: $(parent.document).find(".tabsPageContent").height() - 11 > 0 ? $(parent.document).find(".tabsPageContent").height() - 11 : 500,
             }); 
	    });
        //权限处理
        var $powers={
            "r查看":<%=HasPowerEasyUI(IHISCETeim.Web.Permission.查看) %> 
        };

        $(document).ready(function () {
            var $tab_toolbar=$("#tab_toolbar");
            $tab_toolbar.find("a").each(function(){
                var $per=$(this).attr("Permission");
                var pt= $powers[$per]==undefined || null?true:$powers[$per];
                $(this).linkbutton(pt?'enable': 'disable');
            })
           
            //加载数据
            InitGird();           
        })
        //加载列表数据
        function InitGird() {
            $('#dg').datagrid({ 
                url: location.href, //请求数据的页面
                sortName: 'JingXiaoShang', //排序字段
                sortOrder: 'desc', //排序类型
                idField: 'JingXiaoShang', //标识字段,主键
                iconCls: '', //标题左边的图标
                width: '100%', //宽度    
                height: $(parent.document).find(".tabsPageContent").height() - 11 > 0 ? $(parent.document).find(".tabsPageContent").height() - 11 : 500,
                nowrap: false, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                singleSelect: true, //是否只能选中一条
                remoteSort: true, //定义是否从服务器给数据排序
                frozenColumns: [[//冻结的列，不会随横向滚动轴移动
                    {title:'经销商',field:'JingXiaoShang',width: 100,sortable:true,rowspan:2,formatter:function(value, row, index){
                         if(value==undefined)
                                return "合计:";
                        return value;
                    }},                	
                    { title: '未支付金额', field: 'WeiShouKuanXiang', width: 100,rowspan:2,formatter:hrefClickProc},
                    { title: '未到期金额', field: 'WeiDaoQiKuanXing', width: 100,rowspan:2,formatter:hrefClickProc},
				]],
                columns: [
                    [
                        {title:'逾期天数',colspan:15}
                    ],
                    [
                    { title: '0－30天', field: 'Day30', width: 80,formatter:hrefClickProc},
                    { title: '31－60天', field: 'Day60', width: 80,formatter:hrefClickProc},
                    { title: '61－90天', field: 'Day90', width: 80,formatter:hrefClickProc},
                    { title: '91－120天', field: 'Day120', width: 80,formatter:hrefClickProc},
                    { title: '121－150天', field: 'Day150', width: 80,formatter:hrefClickProc},
                    { title: '151－180天', field: 'Day180', width: 80,formatter:hrefClickProc},
                    { title: '181－210天', field: 'Day210', width: 80,formatter:hrefClickProc},
                    { title: '211－240天', field: 'Day240', width: 80,formatter:hrefClickProc},
                    { title: '241－270天', field: 'Day270', width: 80,formatter:hrefClickProc},
                    { title: '271－300天', field: 'Day300', width: 80,formatter:hrefClickProc},
                    { title: '301－330天', field: 'Day330', width: 80,formatter:hrefClickProc},
                    { title: '331－360天', field: 'Day360', width: 80,formatter:hrefClickProc},
                    { title: '361－720天', field: 'Day720', width: 80,formatter:hrefClickProc},
                    { title: '721－1080天', field: 'Day1080', width: 80,formatter:hrefClickProc},
                    { title: '1080天以上', field: 'Day1080More', width: 80,formatter:hrefClickProc}           
                ]],
                toolbar: "#tab_toolbar",
                queryParams: { "action": "query" },
                pagination: false, //是否开启分页
                pageNumber: 1, //默认索引页
                pageSize: <%=numPerPage %>, //默认一页数据条数
                pageList:<%=SetnumPerPage() %>,
                rownumbers: true, //行号
                showFooter: true,
                onHeaderContextMenu: function(e, field){
					e.preventDefault();
					if (!$('#tmenu').length){
						createColumnMenu();
					}
					$('#tmenu').menu('show', {
						left:e.pageX,
						top:e.pageY
					});
				},
                onRowContextMenu:function(e,rowIndex,rowData)
                {
                    e.preventDefault();
					if (!$('#tmenu').length){
						createColumnMenu();
					}
					$('#tmenu').menu('show', {
						left:e.pageX,
						top:e.pageY
					});
                },
                onClickCell:function(rowIndex,field,value){   
                    if(value==undefined || value==0 || field=="JingXiaoShang")
                        return false;     
                    var JingXiaoShang=$('#dg').datagrid('getRows')[rowIndex].JingXiaoShang  

                    if(field=="WeiShouKuanXiang")
                    {
                        var rel = "ReportZhanLin1Detail";
                        var url = "FTradeModel/ReportZhanLin1EasyUI.aspx?IsShowFenQi=0&JingXiaoShang=" +  encodeURI(JingXiaoShang);
                        var title = "查看["+JingXiaoShang+"]未支付明细";
                        var options = { width: 850, height: 450, max: false, mask: true, maxable: false, minable: false, fresh: true, resizable: false, drawable: true };
                        top.navTab.openTab(rel, url, { title: title, fresh: true, external: true });
                        return false;
                    }
                    
                    var rel = "ReportZhanLin2EasyUI_YuQiDetail";
                    var url = "FTradeModel/ReportZhanLin2EasyUI_YuQiDetail.aspx?IsShowFenQi=0&JingXiaoShang=" +  encodeURI(JingXiaoShang)+"&yuqitag="+field;
                    var title = field=="WeiDaoQiKuanXing"?"查看["+JingXiaoShang+"]未到期金额明细":"查看["+JingXiaoShang+"]逾期明细";
                    var options = { width: 850, height: 450, max: false, mask: true, maxable: false, minable: false, fresh: true, resizable: false, drawable: true };                          
                    top.navTab.openTab(rel, url, { title: title, fresh: true, external: true });
                    return false;
                }
            });

        }       
        /*每行的操作处理*/
        function hrefClickProc(value, row, index)
        {
            if(value==undefined && value=="")
                return "";
            if(row.JingXiaoShang=="" || row.JingXiaoShang==undefined)
                return milliformatter(value);
            return "<a href='#'>"+milliformatter(value,2)+"</a>"
        }
        /*列表头部*/
      // var ColumnFields={Day30:"0－30天",Day60:"31－60天",Day90:"61－90天",Day120:"91－120天",Day150:"121－150天",Day180:"151－180天",Day210:"181－210天",Day240:"211－240天",Day270:"241－270天",Day300:"271－300天",Day330:"301－330天",Day360:"331－360天",Day360More:"361天以上",};
       function createColumnMenu(){
			var tmenu = $('<div id="tmenu" style="width:100px;"></div>').appendTo('body');
			var fields = $('#dg').datagrid('getColumnFields');
			for(var i=0; i<fields.length; i++){
				$('<div data-options="name:\''+fields[i]+'\',iconCls:\'icon-ok\'" />').html($('#dg').datagrid('getColumnOption',fields[i]).title).appendTo(tmenu);
			}
			tmenu.menu({
				onClick: function(item){
					if (item.iconCls=='icon-ok'){                       
						$('#dg').datagrid('hideColumn', item.name);
						tmenu.menu('setIcon', {
							target: item.target,
							iconCls: 'icon-empty'
						});
					} else {
						$('#dg').datagrid('showColumn', item.name);
						tmenu.menu('setIcon', {
							target: item.target,
							iconCls: 'icon-ok'
						});
					}
				}
			});
		}
        
    </script>
    <script>
        //操作功能JS
        //打开高级查找窗口
        function onAdjSearch() {
            $("#tab_search").dialog("open");
            $("#search-buttons").find("#btn_search").one("click", function () {
                var query = $("#tab_search").serializeJSON(); // GetInputData("tab_search", "query");
                //处理多值情况
                var xxx = ""
                $("#tab_search").find("input[name='XiaoShouLeiXing']").each(function () {
                    xxx += "" + $(this).val() + ","
                });
                // alert(xxx);
                query.action = "query";
                query.XiaoShouLeiXing = xxx;

                $('#dg').datagrid("options").queryParams = query;
                $('#dg').datagrid('load');
                $("#tab_search").dialog("close");
                return false;

            });
        }
        //导出管控表
        function onExportList() {
           
            //处理多值情况
            var xxx = ""
            $("#tab_search").find("input[name='XiaoShouLeiXing']").each(function () {
                xxx += "" + $(this).val() + ","
            });
             //alert(xxx);

            var href = "<%= ExportExcelWebUrl%>/FTradeModel/FTradeExportReport2.aspx?uid=<%=User.UserId %>&JingXiaoShang=" + $("#tab_search").find("input[name='JingXiaoShang']").val() + "&XiaoShouLeiXing=" + xxx;
            top.window.open(href, "");
            return false;
        }
       

    </script>
</head>
<body style="margin:1px;" >
    <div id="dg">
        
    </div>
    <div id="tab_toolbar" style="padding:2px;">  
        <span style="line-height:26px;width:60px; font-weight:bold; color:Red; "><%=base.GetLastUpdate("FTradeCatheringListEasyUI,FTradeReceivablesListEasyUI") %></span>
        <a href="#" title="高级查找" class="easyui-linkbutton" iconcls="icon-search" plain="true" onclick="return　onAdjSearch(this);" Permission="">查找</a>
        <span></span>
       <a href="#"  class="easyui-linkbutton" iconcls="icon-btnDown" plain="true" onclick="return onExportList();" Permission="r导出">导出</a>
    </div>   
    <div id="tab_search" title="查询条件" style=" height:250px; width:500px;" class="easyui-dialog" modal="true" closed="true" buttons="#search-buttons">
       
        <table class="table_search" width="100%" style=" line-height:21px;">
            <tr>
                <td>经销商:</td>
                <td ><input  name="JingXiaoShang"    value="<%=JingXiaoShang %>"  mustMatch="true" swidth="300" showinputid=""/></td>
                <td></td>
                <td ></td>
            </tr>
            <tr>
                <td>收款条款:</td>
                <td colspan="3">
                     <input name="XiaoShouLeiXing"  class="easyui-combobox" value="<%=XiaoShouLeiXing %>" data-options="
		                    valueField: 'label',
		                    textField: 'value', multiple:true,width:400,
		                    data: [
                            <%=GetXiaoShouLeiXing() %>
                            ]" />
                </td>
            </tr>
            <%--<tr>
                <td>机号:</td>
                <td colspan=3""><input  name="JiHao" value="" /></td>
               
            </tr>
            <tr>
                <td>
                    销售时间：
                </td>
                <td Colspan="3">                    
                    从<input name="XiaoShouShiJianFrom" class="easyui-datebox" type="text" value="" />
                    到<input name="XiaoShouShiJianTo" type="text" class="easyui-datebox" value="" />
                </td>
            </tr>--%>
        </table>
        <div id="search-buttons">
            <a id="btn_search" href="javascript:;" class="easyui-linkbutton" iconcls="icon-search" plain="true">提交</a> 
            <a href="javascript:;" class="easyui-linkbutton" onclick="$('#tab_search').dialog('close');return false;" iconcls="icon-cancel" plain="true">取消</a>
        </div>
    </div>
</body>
</html>